<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="snake.css">
</head>
<body>
    <script>
        //地图显示
        function SnakeMap(){

        }
        SnakeMap.prototype.show = function(){
            let divDom = document.createElement('div');
            divDom.className = 'map';
            document.body.appendChild(divDom);
        }
        let map = new SnakeMap;
        map.show();
        //食物显示
        function Food(){

        }
        Food.prototype.show = function(){
            let divDom = document.createElement('div');
            divDom.className = 'food';
            divDom.style.position = 'absolute';
            divDom.style.top = this.makeRandom(0,29)*20+'px';
            divDom.style.left = this.makeRandom(0,39)*20+'px';
            document.querySelector('.map').appendChild(divDom);
        }
        Food.prototype.makeRandom = function(min,max){
            return Math.floor(Math.random()*(max-min+1)+min);
        }
        let food = new Food;
        food.show();
    </script>
</body>
</html>